﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace YodaMaster.Models
{
    public class ConvertDatetime
    {
        public DateTime time1 { get; set; }
        public DateTime time2 { get; set; }
        public int ind1 { get; set; }
        public int ind2 { get; set; }


        public void Convert(TableModel model)
        {
            time1 = model.time_start;
            time2 = model.time_end;

            int count = 0;

            if (time1.Day == 1) // sunday
            {
                if (time1.Hour == 8 && time1.Minute == 0)
                    model.sunday[0] = 1;
                else if (time1.Hour == 8 && time1.Minute == 30)
                    model.sunday[1] = 1;
                else if (time1.Hour == 9 && time1.Minute == 0)
                    model.sunday[2] = 1;
                else if (time1.Hour == 9 && time1.Minute == 30)
                    model.sunday[3] = 1;
                 else if (time1.Hour == 10 && time1.Minute == 0)
                    model.sunday[4] = 1;
                else if (time1.Hour == 10 && time1.Minute == 30)
                    model.sunday[5] = 1;
                else if (time1.Hour == 11 && time1.Minute == 0)
                    model.sunday[6] = 1;
                else if (time1.Hour == 11 && time1.Minute == 30)
                    model.sunday[7] = 1;
                else if (time1.Hour == 12 && time1.Minute == 0)
                    model.sunday[8] = 1;
                else if (time1.Hour == 12 && time1.Minute == 30)
                    model.sunday[9] = 1;
                else if (time1.Hour == 13 && time1.Minute == 0)
                    model.sunday[10] = 1;
                else if (time1.Hour == 13 && time1.Minute == 30)
                    model.sunday[11] = 1;
                else if (time1.Hour == 14 && time1.Minute == 0)
                    model.sunday[12] = 1;
                else if (time1.Hour == 14 && time1.Minute == 30)
                    model.sunday[13] = 1;
                else if (time1.Hour == 15 && time1.Minute == 0)
                    model.sunday[14] = 1;
                else if (time1.Hour == 15 && time1.Minute == 30)
                    model.sunday[15] = 1;
                else if (time1.Hour == 16 && time1.Minute == 0)
                    model.sunday[16] = 1;
                else if (time1.Hour == 16 && time1.Minute == 30)
                    model.sunday[17] = 1;
                else if (time1.Hour == 17 && time1.Minute == 0)
                    model.sunday[18] = 1;
                else if (time1.Hour == 17 && time1.Minute == 30)
                    model.sunday[19] = 1;
                else if (time1.Hour == 18 && time1.Minute == 0)
                    model.sunday[20] = 1;
                else if (time1.Hour == 18 && time1.Minute == 30)
                    model.sunday[21] = 1;
                else if (time1.Hour == 19 && time1.Minute == 0)
                    model.sunday[22] = 1;
                else if (time1.Hour == 19 && time1.Minute == 30)
                    model.sunday[23] = 1;
                else if (time1.Hour == 20 && time1.Minute == 0)
                    model.sunday[24] = 1;
                else if (time1.Hour == 20 && time1.Minute == 30)
                    model.sunday[25] = 1;
                else if (time1.Hour == 21 && time1.Minute == 0)
                    model.sunday[26] = 1;
                else if (time1.Hour == 21 && time1.Minute == 30)
                    model.sunday[27] = 1;
                else if (time1.Hour == 22 && time1.Minute == 0)
                    model.sunday[28] = 1;
                else if (time1.Hour == 22 && time1.Minute == 30)
                    model.sunday[29] = 1;

                if (time2.Hour == 8 && time2.Minute == 0)
                    model.sunday[0] = 1;
                else if (time2.Hour == 8 && time2.Minute == 30)
                    model.sunday[1] = 1;
                else if (time2.Hour == 9 && time2.Minute == 0)
                    model.sunday[2] = 1;
                else if (time2.Hour == 9 && time2.Minute == 30)
                    model.sunday[3] = 1;
                else if (time2.Hour == 10 && time2.Minute == 0)
                    model.sunday[4] = 1;
                else if (time2.Hour == 10 && time2.Minute == 30)
                    model.sunday[5] = 1;
                else if (time2.Hour == 11 && time2.Minute == 0)
                    model.sunday[6] = 1;
                else if (time2.Hour == 11 && time2.Minute == 30)
                    model.sunday[7] = 1;
                else if (time2.Hour == 12 && time2.Minute == 0)
                    model.sunday[8] = 1;
                else if (time2.Hour == 12 && time2.Minute == 30)
                    model.sunday[9] = 1;
                else if (time2.Hour == 13 && time2.Minute == 0)
                    model.sunday[10] = 1;
                else if (time2.Hour == 13 && time2.Minute == 30)
                    model.sunday[11] = 1;
                else if (time2.Hour == 14 && time2.Minute == 0)
                    model.sunday[12] = 1;
                else if (time2.Hour == 14 && time2.Minute == 30)
                    model.sunday[13] = 1;
                else if (time2.Hour == 15 && time2.Minute == 0)
                    model.sunday[14] = 1;
                else if (time2.Hour == 15 && time2.Minute == 30)
                    model.sunday[15] = 1;
                else if (time2.Hour == 16 && time2.Minute == 0)
                    model.sunday[16] = 1;
                else if (time2.Hour == 16 && time2.Minute == 30)
                    model.sunday[17] = 1;
                else if (time2.Hour == 17 && time2.Minute == 0)
                    model.sunday[18] = 1;
                else if (time2.Hour == 17 && time2.Minute == 30)
                    model.sunday[19] = 1;
                else if (time2.Hour == 18 && time2.Minute == 0)
                    model.sunday[20] = 1;
                else if (time2.Hour == 18 && time2.Minute == 30)
                    model.sunday[21] = 1;
                else if (time2.Hour == 19 && time2.Minute == 0)
                    model.sunday[22] = 1;
                else if (time2.Hour == 19 && time2.Minute == 30)
                    model.sunday[23] = 1;
                else if (time2.Hour == 20 && time2.Minute == 0)
                    model.sunday[24] = 1;
                else if (time2.Hour == 20 && time2.Minute == 30)
                    model.sunday[25] = 1;
                else if (time2.Hour == 21 && time2.Minute == 0)
                    model.sunday[26] = 1;
                else if (time2.Hour == 21 && time2.Minute == 30)
                    model.sunday[27] = 1;
                else if (time2.Hour == 22 && time2.Minute == 0)
                    model.sunday[28] = 1;
                else if (time2.Hour == 22 && time2.Minute == 30)
                    model.sunday[29] = 1;
                
                 for (int i = 0; i < 30; i++)
                 {
                     if (model.sunday[i] == 1 && count == 0)
                     {
                         ind1 = i;
                         count++;
                     }
                     else if (model.sunday[i] == 1 && count == 1)
                     {
                         ind2 = i;
                         model.sunday[i] = 0;
                         break;
                     }
                 }
                 for (int i = ind1; i < ind2; i++)
                      model.sunday[i] = 1;

                        
                
            }
            if (time1.Day == 2) // monday
            {
                if (time1.Hour == 8 && time1.Minute == 0)
                    model.monday[0] = 1;
                else if (time1.Hour == 8 && time1.Minute == 30)
                    model.monday[1] = 1;
                else if (time1.Hour == 9 && time1.Minute == 0)
                    model.monday[2] = 1;
                else if (time1.Hour == 9 && time1.Minute == 30)
                    model.monday[3] = 1;
                else if (time1.Hour == 10 && time1.Minute == 0)
                    model.monday[4] = 1;
                else if (time1.Hour == 10 && time1.Minute == 30)
                    model.monday[5] = 1;
                else if (time1.Hour == 11 && time1.Minute == 0)
                    model.monday[6] = 1;
                else if (time1.Hour == 11 && time1.Minute == 30)
                    model.monday[7] = 1;
                else if (time1.Hour == 12 && time1.Minute == 0)
                    model.monday[8] = 1;
                else if (time1.Hour == 12 && time1.Minute == 30)
                    model.monday[9] = 1;
                else if (time1.Hour == 13 && time1.Minute == 0)
                    model.monday[10] = 1;
                else if (time1.Hour == 13 && time1.Minute == 30)
                    model.monday[11] = 1;
                else if (time1.Hour == 14 && time1.Minute == 0)
                    model.monday[12] = 1;
                else if (time1.Hour == 14 && time1.Minute == 30)
                    model.monday[13] = 1;
                else if (time1.Hour == 15 && time1.Minute == 0)
                    model.monday[14] = 1;
                else if (time1.Hour == 15 && time1.Minute == 30)
                    model.monday[15] = 1;
                else if (time1.Hour == 16 && time1.Minute == 0)
                    model.monday[16] = 1;
                else if (time1.Hour == 16 && time1.Minute == 30)
                    model.monday[17] = 1;
                else if (time1.Hour == 17 && time1.Minute == 0)
                    model.monday[18] = 1;
                else if (time1.Hour == 17 && time1.Minute == 30)
                    model.monday[19] = 1;
                else if (time1.Hour == 18 && time1.Minute == 0)
                    model.monday[20] = 1;
                else if (time1.Hour == 18 && time1.Minute == 30)
                    model.monday[21] = 1;
                else if (time1.Hour == 19 && time1.Minute == 0)
                    model.monday[22] = 1;
                else if (time1.Hour == 19 && time1.Minute == 30)
                    model.monday[23] = 1;
                else if (time1.Hour == 20 && time1.Minute == 0)
                    model.monday[24] = 1;
                else if (time1.Hour == 20 && time1.Minute == 30)
                    model.monday[25] = 1;
                else if (time1.Hour == 21 && time1.Minute == 0)
                    model.monday[26] = 1;
                else if (time1.Hour == 21 && time1.Minute == 30)
                    model.monday[27] = 1;
                else if (time1.Hour == 22 && time1.Minute == 0)
                    model.monday[28] = 1;
                else if (time1.Hour == 22 && time1.Minute == 30)
                    model.monday[29] = 1;

                if (time2.Hour == 8 && time2.Minute == 0)
                    model.monday[0] = 1;
                else if (time2.Hour == 8 && time2.Minute == 30)
                    model.monday[1] = 1;
                else if (time2.Hour == 9 && time2.Minute == 0)
                    model.monday[2] = 1;
                else if (time2.Hour == 9 && time2.Minute == 30)
                    model.monday[3] = 1;
                else if (time2.Hour == 10 && time2.Minute == 0)
                    model.monday[4] = 1;
                else if (time2.Hour == 10 && time2.Minute == 30)
                    model.monday[5] = 1;
                else if (time2.Hour == 11 && time2.Minute == 0)
                    model.monday[6] = 1;
                else if (time2.Hour == 11 && time2.Minute == 30)
                    model.monday[7] = 1;
                else if (time2.Hour == 12 && time2.Minute == 0)
                    model.monday[8] = 1;
                else if (time2.Hour == 12 && time2.Minute == 30)
                    model.monday[9] = 1;
                else if (time2.Hour == 13 && time2.Minute == 0)
                    model.monday[10] = 1;
                else if (time2.Hour == 13 && time2.Minute == 30)
                    model.monday[11] = 1;
                else if (time2.Hour == 14 && time2.Minute == 0)
                    model.monday[12] = 1;
                else if (time2.Hour == 14 && time2.Minute == 30)
                    model.monday[13] = 1;
                else if (time2.Hour == 15 && time2.Minute == 0)
                    model.monday[14] = 1;
                else if (time2.Hour == 15 && time2.Minute == 30)
                    model.monday[15] = 1;
                else if (time2.Hour == 16 && time2.Minute == 0)
                    model.monday[16] = 1;
                else if (time2.Hour == 16 && time2.Minute == 30)
                    model.monday[17] = 1;
                else if (time2.Hour == 17 && time2.Minute == 0)
                    model.monday[18] = 1;
                else if (time2.Hour == 17 && time2.Minute == 30)
                    model.monday[19] = 1;
                else if (time2.Hour == 18 && time2.Minute == 0)
                    model.monday[20] = 1;
                else if (time2.Hour == 18 && time2.Minute == 30)
                    model.monday[21] = 1;
                else if (time2.Hour == 19 && time2.Minute == 0)
                    model.monday[22] = 1;
                else if (time2.Hour == 19 && time2.Minute == 30)
                    model.monday[23] = 1;
                else if (time2.Hour == 20 && time2.Minute == 0)
                    model.monday[24] = 1;
                else if (time2.Hour == 20 && time2.Minute == 30)
                    model.monday[25] = 1;
                else if (time2.Hour == 21 && time2.Minute == 0)
                    model.monday[26] = 1;
                else if (time2.Hour == 21 && time2.Minute == 30)
                    model.monday[27] = 1;
                else if (time2.Hour == 22 && time2.Minute == 0)
                    model.monday[28] = 1;
                else if (time2.Hour == 22 && time2.Minute == 30)
                    model.monday[29] = 1;

                
                for (int i = 0; i < 30; i++)
                {
                    if (model.monday[i] == 1 && count == 0)
                    {
                        ind1 = i;
                        count++;
                    }
                    else  if (model.monday[i] == 1 && count == 1)
                    {
                        ind2 = i;
                        model.monday[i] = 0;
                        break;

                    }
                }
                for (int i = ind1; i < ind2; i++)
                    model.monday[i] = 1;
            }
            if (time1.Day == 3) // tuesday
            {
                if (time1.Hour == 8 && time1.Minute == 0)
                    model.tuesday[0] = 1;
                else if (time1.Hour == 8 && time1.Minute == 30)
                    model.tuesday[1] = 1;
                else if (time1.Hour == 9 && time1.Minute == 0)
                    model.tuesday[2] = 1;
                else if (time1.Hour == 9 && time1.Minute == 30)
                    model.tuesday[3] = 1;
                else if (time1.Hour == 10 && time1.Minute == 0)
                    model.tuesday[4] = 1;
                else if (time1.Hour == 10 && time1.Minute == 30)
                    model.tuesday[5] = 1;
                else if (time1.Hour == 11 && time1.Minute == 0)
                    model.tuesday[6] = 1;
                else if (time1.Hour == 11 && time1.Minute == 30)
                    model.tuesday[7] = 1;
                else if (time1.Hour == 12 && time1.Minute == 0)
                    model.tuesday[8] = 1;
                else if (time1.Hour == 12 && time1.Minute == 30)
                    model.tuesday[9] = 1;
                else if (time1.Hour == 13 && time1.Minute == 0)
                    model.tuesday[10] = 1;
                else if (time1.Hour == 13 && time1.Minute == 30)
                    model.tuesday[11] = 1;
                else if (time1.Hour == 14 && time1.Minute == 0)
                    model.tuesday[12] = 1;
                else if (time1.Hour == 14 && time1.Minute == 30)
                    model.tuesday[13] = 1;
                else if (time1.Hour == 15 && time1.Minute == 0)
                    model.tuesday[14] = 1;
                else if (time1.Hour == 15 && time1.Minute == 30)
                    model.tuesday[15] = 1;
                else if (time1.Hour == 16 && time1.Minute == 0)
                    model.tuesday[16] = 1;
                else if (time1.Hour == 16 && time1.Minute == 30)
                    model.tuesday[17] = 1;
                else if (time1.Hour == 17 && time1.Minute == 0)
                    model.tuesday[18] = 1;
                else if (time1.Hour == 17 && time1.Minute == 30)
                    model.tuesday[19] = 1;
                else if (time1.Hour == 18 && time1.Minute == 0)
                    model.tuesday[20] = 1;
                else if (time1.Hour == 18 && time1.Minute == 30)
                    model.tuesday[21] = 1;
                else if (time1.Hour == 19 && time1.Minute == 0)
                    model.tuesday[22] = 1;
                else if (time1.Hour == 19 && time1.Minute == 30)
                    model.tuesday[23] = 1;
                else if (time1.Hour == 20 && time1.Minute == 0)
                    model.tuesday[24] = 1;
                else if (time1.Hour == 20 && time1.Minute == 30)
                    model.tuesday[25] = 1;
                else if (time1.Hour == 21 && time1.Minute == 0)
                    model.tuesday[26] = 1;
                else if (time1.Hour == 21 && time1.Minute == 30)
                    model.tuesday[27] = 1;
                else if (time1.Hour == 22 && time1.Minute == 0)
                    model.tuesday[28] = 1;
                else if (time1.Hour == 22 && time1.Minute == 30)
                    model.tuesday[29] = 1;

                if (time2.Hour == 8 && time2.Minute == 0)
                    model.tuesday[0] = 1;
                else if (time2.Hour == 8 && time2.Minute == 30)
                    model.tuesday[1] = 1;
                else if (time2.Hour == 9 && time2.Minute == 0)
                    model.tuesday[2] = 1;
                else if (time2.Hour == 9 && time2.Minute == 30)
                    model.tuesday[3] = 1;
                else if (time2.Hour == 10 && time2.Minute == 0)
                    model.tuesday[4] = 1;
                else if (time2.Hour == 10 && time2.Minute == 30)
                    model.tuesday[5] = 1;
                else if (time2.Hour == 11 && time2.Minute == 0)
                    model.tuesday[6] = 1;
                else if (time2.Hour == 11 && time2.Minute == 30)
                    model.tuesday[7] = 1;
                else if (time2.Hour == 12 && time2.Minute == 0)
                    model.tuesday[8] = 1;
                else if (time2.Hour == 12 && time2.Minute == 30)
                    model.tuesday[9] = 1;
                else if (time2.Hour == 13 && time2.Minute == 0)
                    model.tuesday[10] = 1;
                else if (time2.Hour == 13 && time2.Minute == 30)
                    model.tuesday[11] = 1;
                else if (time2.Hour == 14 && time2.Minute == 0)
                    model.tuesday[12] = 1;
                else if (time2.Hour == 14 && time2.Minute == 30)
                    model.tuesday[13] = 1;
                else if (time2.Hour == 15 && time2.Minute == 0)
                    model.tuesday[14] = 1;
                else if (time2.Hour == 15 && time2.Minute == 30)
                    model.tuesday[15] = 1;
                else if (time2.Hour == 16 && time2.Minute == 0)
                    model.tuesday[16] = 1;
                else if (time2.Hour == 16 && time2.Minute == 30)
                    model.tuesday[17] = 1;
                else if (time2.Hour == 17 && time2.Minute == 0)
                    model.tuesday[18] = 1;
                else if (time2.Hour == 17 && time2.Minute == 30)
                    model.tuesday[19] = 1;
                else if (time2.Hour == 18 && time2.Minute == 0)
                    model.tuesday[20] = 1;
                else if (time2.Hour == 18 && time2.Minute == 30)
                    model.tuesday[21] = 1;
                else if (time2.Hour == 19 && time2.Minute == 0)
                    model.tuesday[22] = 1;
                else if (time2.Hour == 19 && time2.Minute == 30)
                    model.tuesday[23] = 1;
                else if (time2.Hour == 20 && time2.Minute == 0)
                    model.tuesday[24] = 1;
                else if (time2.Hour == 20 && time2.Minute == 30)
                    model.tuesday[25] = 1;
                else if (time2.Hour == 21 && time2.Minute == 0)
                    model.tuesday[26] = 1;
                else if (time2.Hour == 21 && time2.Minute == 30)
                    model.tuesday[27] = 1;
                else if (time2.Hour == 22 && time2.Minute == 0)
                    model.tuesday[28] = 1;
                else if (time2.Hour == 22 && time2.Minute == 30)
                    model.tuesday[29] = 1;

              
                for (int i = 0; i < 30; i++)
                {
                    if (model.tuesday[i] == 1 && count == 0)
                    {
                        ind1 = i;
                        count++;
                    }
                    else if (model.tuesday[i] == 1 && count == 1)
                    {
                        ind2 = i;
                        model.tuesday[i] = 0;
                        break;

                    }
                }
                for (int i = ind1; i < ind2; i++)
                    model.tuesday[i] = 1;
            }
            if (time1.Day == 4) // wednesday
            {
                if (time1.Hour == 8 && time1.Minute == 0)
                    model.wednesday[0] = 1;
                else if (time1.Hour == 8 && time1.Minute == 30)
                    model.wednesday[1] = 1;
                else if (time1.Hour == 9 && time1.Minute == 0)
                    model.wednesday[2] = 1;
                else if (time1.Hour == 9 && time1.Minute == 30)
                    model.wednesday[3] = 1;
                else if (time1.Hour == 10 && time1.Minute == 0)
                    model.wednesday[4] = 1;
                else if (time1.Hour == 10 && time1.Minute == 30)
                    model.wednesday[5] = 1;
                else if (time1.Hour == 11 && time1.Minute == 0)
                    model.wednesday[6] = 1;
                else if (time1.Hour == 11 && time1.Minute == 30)
                    model.wednesday[7] = 1;
                else if (time1.Hour == 12 && time1.Minute == 0)
                    model.wednesday[8] = 1;
                else if (time1.Hour == 12 && time1.Minute == 30)
                    model.wednesday[9] = 1;
                else if (time1.Hour == 13 && time1.Minute == 0)
                    model.wednesday[10] = 1;
                else if (time1.Hour == 13 && time1.Minute == 30)
                    model.wednesday[11] = 1;
                else if (time1.Hour == 14 && time1.Minute == 0)
                    model.wednesday[12] = 1;
                else if (time1.Hour == 14 && time1.Minute == 30)
                    model.wednesday[13] = 1;
                else if (time1.Hour == 15 && time1.Minute == 0)
                    model.wednesday[14] = 1;
                else if (time1.Hour == 15 && time1.Minute == 30)
                    model.wednesday[15] = 1;
                else if (time1.Hour == 16 && time1.Minute == 0)
                    model.wednesday[16] = 1;
                else if (time1.Hour == 16 && time1.Minute == 30)
                    model.wednesday[17] = 1;
                else if (time1.Hour == 17 && time1.Minute == 0)
                    model.wednesday[18] = 1;
                else if (time1.Hour == 17 && time1.Minute == 30)
                    model.wednesday[19] = 1;
                else if (time1.Hour == 18 && time1.Minute == 0)
                    model.wednesday[20] = 1;
                else if (time1.Hour == 18 && time1.Minute == 30)
                    model.wednesday[21] = 1;
                else if (time1.Hour == 19 && time1.Minute == 0)
                    model.wednesday[22] = 1;
                else if (time1.Hour == 19 && time1.Minute == 30)
                    model.wednesday[23] = 1;
                else if (time1.Hour == 20 && time1.Minute == 0)
                    model.wednesday[24] = 1;
                else if (time1.Hour == 20 && time1.Minute == 30)
                    model.wednesday[25] = 1;
                else if (time1.Hour == 21 && time1.Minute == 0)
                    model.wednesday[26] = 1;
                else if (time1.Hour == 21 && time1.Minute == 30)
                    model.wednesday[27] = 1;
                else if (time1.Hour == 22 && time1.Minute == 0)
                    model.wednesday[28] = 1;
                else if (time1.Hour == 22 && time1.Minute == 30)
                    model.wednesday[29] = 1;

                if (time2.Hour == 8 && time2.Minute == 0)
                    model.wednesday[0] = 1;
                else if (time2.Hour == 8 && time2.Minute == 30)
                    model.wednesday[1] = 1;
                else if (time2.Hour == 9 && time2.Minute == 0)
                    model.wednesday[2] = 1;
                else if (time2.Hour == 9 && time2.Minute == 30)
                    model.wednesday[3] = 1;
                else if (time2.Hour == 10 && time2.Minute == 0)
                    model.wednesday[4] = 1;
                else if (time2.Hour == 10 && time2.Minute == 30)
                    model.wednesday[5] = 1;
                else if (time2.Hour == 11 && time2.Minute == 0)
                    model.wednesday[6] = 1;
                else if (time2.Hour == 11 && time2.Minute == 30)
                    model.wednesday[7] = 1;
                else if (time2.Hour == 12 && time2.Minute == 0)
                    model.wednesday[8] = 1;
                else if (time2.Hour == 12 && time2.Minute == 30)
                    model.wednesday[9] = 1;
                else if (time2.Hour == 13 && time2.Minute == 0)
                    model.wednesday[10] = 1;
                else if (time2.Hour == 13 && time2.Minute == 30)
                    model.wednesday[11] = 1;
                else if (time2.Hour == 14 && time2.Minute == 0)
                    model.wednesday[12] = 1;
                else if (time2.Hour == 14 && time2.Minute == 30)
                    model.wednesday[13] = 1;
                else if (time2.Hour == 15 && time2.Minute == 0)
                    model.wednesday[14] = 1;
                else if (time2.Hour == 15 && time2.Minute == 30)
                    model.wednesday[15] = 1;
                else if (time2.Hour == 16 && time2.Minute == 0)
                    model.wednesday[16] = 1;
                else if (time2.Hour == 16 && time2.Minute == 30)
                    model.wednesday[17] = 1;
                else if (time2.Hour == 17 && time2.Minute == 0)
                    model.wednesday[18] = 1;
                else if (time2.Hour == 17 && time2.Minute == 30)
                    model.wednesday[19] = 1;
                else if (time2.Hour == 18 && time2.Minute == 0)
                    model.wednesday[20] = 1;
                else if (time2.Hour == 18 && time2.Minute == 30)
                    model.wednesday[21] = 1;
                else if (time2.Hour == 19 && time2.Minute == 0)
                    model.wednesday[22] = 1;
                else if (time2.Hour == 19 && time2.Minute == 30)
                    model.wednesday[23] = 1;
                else if (time2.Hour == 20 && time2.Minute == 0)
                    model.wednesday[24] = 1;
                else if (time2.Hour == 20 && time2.Minute == 30)
                    model.wednesday[25] = 1;
                else if (time2.Hour == 21 && time2.Minute == 0)
                    model.wednesday[26] = 1;
                else if (time2.Hour == 21 && time2.Minute == 30)
                    model.wednesday[27] = 1;
                else if (time2.Hour == 22 && time2.Minute == 0)
                    model.wednesday[28] = 1;
                else if (time2.Hour == 22 && time2.Minute == 30)
                    model.wednesday[29] = 1;

               
                for (int i = 0; i < 30; i++)
                {
                    if (model.wednesday[i] == 1 && count == 0)
                    {
                        ind1 = i;
                        count++;
                    }
                   else if (model.wednesday[i] == 1 && count == 1)
                    {
                        ind2 = i;
                        model.wednesday[i] = 0;
                        break;

                    }
                }
                for (int i = ind1; i < ind2; i++)
                    model.wednesday[i] = 1;

            }
            if (time1.Day == 5) // thursday
            {
                if (time1.Hour == 8 && time1.Minute == 0)
                    model.thursday[0] = 1;
                else if (time1.Hour == 8 && time1.Minute == 30)
                    model.thursday[1] = 1;
                else if (time1.Hour == 9 && time1.Minute == 0)
                    model.thursday[2] = 1;
                else if (time1.Hour == 9 && time1.Minute == 30)
                    model.thursday[3] = 1;
                else if (time1.Hour == 10 && time1.Minute == 0)
                    model.thursday[4] = 1;
                else if (time1.Hour == 10 && time1.Minute == 30)
                    model.thursday[5] = 1;
                else if (time1.Hour == 11 && time1.Minute == 0)
                    model.thursday[6] = 1;
                else if (time1.Hour == 11 && time1.Minute == 30)
                    model.thursday[7] = 1;
                else if (time1.Hour == 12 && time1.Minute == 0)
                    model.thursday[8] = 1;
                else if (time1.Hour == 12 && time1.Minute == 30)
                    model.thursday[9] = 1;
                else if (time1.Hour == 13 && time1.Minute == 0)
                    model.thursday[10] = 1;
                else if (time1.Hour == 13 && time1.Minute == 30)
                    model.thursday[11] = 1;
                else if (time1.Hour == 14 && time1.Minute == 0)
                    model.thursday[12] = 1;
                else if (time1.Hour == 14 && time1.Minute == 30)
                    model.thursday[13] = 1;
                else if (time1.Hour == 15 && time1.Minute == 0)
                    model.thursday[14] = 1;
                else if (time1.Hour == 15 && time1.Minute == 30)
                    model.thursday[15] = 1;
                else if (time1.Hour == 16 && time1.Minute == 0)
                    model.thursday[16] = 1;
                else if (time1.Hour == 16 && time1.Minute == 30)
                    model.thursday[17] = 1;
                else if (time1.Hour == 17 && time1.Minute == 0)
                    model.thursday[18] = 1;
                else if (time1.Hour == 17 && time1.Minute == 30)
                    model.thursday[19] = 1;
                else if (time1.Hour == 18 && time1.Minute == 0)
                    model.thursday[20] = 1;
                else if (time1.Hour == 18 && time1.Minute == 30)
                    model.thursday[21] = 1;
                else if (time1.Hour == 19 && time1.Minute == 0)
                    model.thursday[22] = 1;
                else if (time1.Hour == 19 && time1.Minute == 30)
                    model.thursday[23] = 1;
                else if (time1.Hour == 20 && time1.Minute == 0)
                    model.thursday[24] = 1;
                else if (time1.Hour == 20 && time1.Minute == 30)
                    model.thursday[25] = 1;
                else if (time1.Hour == 21 && time1.Minute == 0)
                    model.thursday[26] = 1;
                else if (time1.Hour == 21 && time1.Minute == 30)
                    model.thursday[27] = 1;
                else if (time1.Hour == 22 && time1.Minute == 0)
                    model.thursday[28] = 1;
                else if (time1.Hour == 22 && time1.Minute == 30)
                    model.thursday[29] = 1;

                if (time2.Hour == 8 && time2.Minute == 0)
                    model.thursday[0] = 1;
                else if (time2.Hour == 8 && time2.Minute == 30)
                    model.thursday[1] = 1;
                else if (time2.Hour == 9 && time2.Minute == 0)
                    model.thursday[2] = 1;
                else if (time2.Hour == 9 && time2.Minute == 30)
                    model.thursday[3] = 1;
                else if (time2.Hour == 10 && time2.Minute == 0)
                    model.thursday[4] = 1;
                else if (time2.Hour == 10 && time2.Minute == 30)
                    model.thursday[5] = 1;
                else if (time2.Hour == 11 && time2.Minute == 0)
                    model.thursday[6] = 1;
                else if (time2.Hour == 11 && time2.Minute == 30)
                    model.thursday[7] = 1;
                else if (time2.Hour == 12 && time2.Minute == 0)
                    model.thursday[8] = 1;
                else if (time2.Hour == 12 && time2.Minute == 30)
                    model.thursday[9] = 1;
                else if (time2.Hour == 13 && time2.Minute == 0)
                    model.thursday[10] = 1;
                else if (time2.Hour == 13 && time2.Minute == 30)
                    model.thursday[11] = 1;
                else if (time2.Hour == 14 && time2.Minute == 0)
                    model.thursday[12] = 1;
                else if (time2.Hour == 14 && time2.Minute == 30)
                    model.thursday[13] = 1;
                else if (time2.Hour == 15 && time2.Minute == 0)
                    model.thursday[14] = 1;
                else if (time2.Hour == 15 && time2.Minute == 30)
                    model.thursday[15] = 1;
                else if (time2.Hour == 16 && time2.Minute == 0)
                    model.thursday[16] = 1;
                else if (time2.Hour == 16 && time2.Minute == 30)
                    model.thursday[17] = 1;
                else if (time2.Hour == 17 && time2.Minute == 0)
                    model.thursday[18] = 1;
                else if (time2.Hour == 17 && time2.Minute == 30)
                    model.thursday[19] = 1;
                else if (time2.Hour == 18 && time2.Minute == 0)
                    model.thursday[20] = 1;
                else if (time2.Hour == 18 && time2.Minute == 30)
                    model.thursday[21] = 1;
                else if (time2.Hour == 19 && time2.Minute == 0)
                    model.thursday[22] = 1;
                else if (time2.Hour == 19 && time2.Minute == 30)
                    model.thursday[23] = 1;
                else if (time2.Hour == 20 && time2.Minute == 0)
                    model.thursday[24] = 1;
                else if (time2.Hour == 20 && time2.Minute == 30)
                    model.thursday[25] = 1;
                else if (time2.Hour == 21 && time2.Minute == 0)
                    model.thursday[26] = 1;
                else if (time2.Hour == 21 && time2.Minute == 30)
                    model.thursday[27] = 1;
                else if (time2.Hour == 22 && time2.Minute == 0)
                    model.thursday[28] = 1;
                else if (time2.Hour == 22 && time2.Minute == 30)
                    model.thursday[29] = 1;

              
                for (int i = 0; i < 30; i++)
                {
                    if (model.thursday[i] == 1 && count == 0)
                    {
                        ind1 = i;
                        count++;
                    }
                    else if (model.thursday[i] == 1 && count == 1)
                    {
                        ind2 = i;
                        model.thursday[i] = 0;
                        break;

                    }
                }
                for (int i = ind1; i < ind2; i++)
                    model.thursday[i] = 1;
            }
            if (time1.Day == 6) // friday
            {
                if (time1.Hour == 8 && time1.Minute == 0)
                    model.friday[0] = 1;
                else if (time1.Hour == 8 && time1.Minute == 30)
                    model.friday[1] = 1;
                else if (time1.Hour == 9 && time1.Minute == 0)
                    model.friday[2] = 1;
                else if (time1.Hour == 9 && time1.Minute == 30)
                    model.friday[3] = 1;
                else if (time1.Hour == 10 && time1.Minute == 0)
                    model.friday[4] = 1;
                else if (time1.Hour == 10 && time1.Minute == 30)
                    model.friday[5] = 1;
                else if (time1.Hour == 11 && time1.Minute == 0)
                    model.friday[6] = 1;
                else if (time1.Hour == 11 && time1.Minute == 30)
                    model.friday[7] = 1;
                else if (time1.Hour == 12 && time1.Minute == 0)
                    model.friday[8] = 1;
                else if (time1.Hour == 12 && time1.Minute == 30)
                    model.friday[9] = 1;
                else if (time1.Hour == 13 && time1.Minute == 0)
                    model.friday[10] = 1;
                else if (time1.Hour == 13 && time1.Minute == 30)
                    model.friday[11] = 1;
                else if (time1.Hour == 14 && time1.Minute == 0)
                    model.friday[12] = 1;
                else if (time1.Hour == 14 && time1.Minute == 30)
                    model.friday[13] = 1;
                else if (time1.Hour == 15 && time1.Minute == 0)
                    model.friday[14] = 1;
                else if (time1.Hour == 15 && time1.Minute == 30)
                    model.friday[15] = 1;
                else if (time1.Hour == 16 && time1.Minute == 0)
                    model.friday[16] = 1;
                else if (time1.Hour == 16 && time1.Minute == 30)
                    model.friday[17] = 1;
                else if (time1.Hour == 17 && time1.Minute == 0)
                    model.friday[18] = 1;
                else if (time1.Hour == 17 && time1.Minute == 30)
                    model.friday[19] = 1;
                else if (time1.Hour == 18 && time1.Minute == 0)
                    model.friday[20] = 1;
                else if (time1.Hour == 18 && time1.Minute == 30)
                    model.friday[21] = 1;
                else if (time1.Hour == 19 && time1.Minute == 0)
                    model.friday[22] = 1;
                else if (time1.Hour == 19 && time1.Minute == 30)
                    model.friday[23] = 1;
                else if (time1.Hour == 20 && time1.Minute == 0)
                    model.friday[24] = 1;
                else if (time1.Hour == 20 && time1.Minute == 30)
                    model.friday[25] = 1;
                else if (time1.Hour == 21 && time1.Minute == 0)
                    model.friday[26] = 1;
                else if (time1.Hour == 21 && time1.Minute == 30)
                    model.friday[27] = 1;
                else if (time1.Hour == 22 && time1.Minute == 0)
                    model.friday[28] = 1;
                else if (time1.Hour == 22 && time1.Minute == 30)
                    model.friday[29] = 1;

                if (time2.Hour == 8 && time2.Minute == 0)
                    model.friday[0] = 1;
                else if (time2.Hour == 8 && time2.Minute == 30)
                    model.friday[1] = 1;
                else if (time2.Hour == 9 && time2.Minute == 0)
                    model.friday[2] = 1;
                else if (time2.Hour == 9 && time2.Minute == 30)
                    model.friday[3] = 1;
                else if (time2.Hour == 10 && time2.Minute == 0)
                    model.friday[4] = 1;
                else if (time2.Hour == 10 && time2.Minute == 30)
                    model.friday[5] = 1;
                else if (time2.Hour == 11 && time2.Minute == 0)
                    model.friday[6] = 1;
                else if (time2.Hour == 11 && time2.Minute == 30)
                    model.friday[7] = 1;
                else if (time2.Hour == 12 && time2.Minute == 0)
                    model.friday[8] = 1;
                else if (time2.Hour == 12 && time2.Minute == 30)
                    model.friday[9] = 1;
                else if (time2.Hour == 13 && time2.Minute == 0)
                    model.friday[10] = 1;
                else if (time2.Hour == 13 && time2.Minute == 30)
                    model.friday[11] = 1;
                else if (time2.Hour == 14 && time2.Minute == 0)
                    model.friday[12] = 1;
                else if (time2.Hour == 14 && time2.Minute == 30)
                    model.friday[13] = 1;
                else if (time2.Hour == 15 && time2.Minute == 0)
                    model.friday[14] = 1;
                else if (time2.Hour == 15 && time2.Minute == 30)
                    model.friday[15] = 1;
                else if (time2.Hour == 16 && time2.Minute == 0)
                    model.friday[16] = 1;
                else if (time2.Hour == 16 && time2.Minute == 30)
                    model.friday[17] = 1;
                else if (time2.Hour == 17 && time2.Minute == 0)
                    model.friday[18] = 1;
                else if (time2.Hour == 17 && time2.Minute == 30)
                    model.friday[19] = 1;
                else if (time2.Hour == 18 && time2.Minute == 0)
                    model.friday[20] = 1;
                else if (time2.Hour == 18 && time2.Minute == 30)
                    model.friday[21] = 1;
                else if (time2.Hour == 19 && time2.Minute == 0)
                    model.friday[22] = 1;
                else if (time2.Hour == 19 && time2.Minute == 30)
                    model.friday[23] = 1;
                else if (time2.Hour == 20 && time2.Minute == 0)
                    model.friday[24] = 1;
                else if (time2.Hour == 20 && time2.Minute == 30)
                    model.friday[25] = 1;
                else if (time2.Hour == 21 && time2.Minute == 0)
                    model.friday[26] = 1;
                else if (time2.Hour == 21 && time2.Minute == 30)
                    model.friday[27] = 1;
                else if (time2.Hour == 22 && time2.Minute == 0)
                    model.friday[28] = 1;
                else if (time2.Hour == 22 && time2.Minute == 30)
                    model.friday[29] = 1;

           
                for (int i = 0; i < 30; i++)
                {
                    if (model.friday[i] == 1 && count == 0)
                    {
                        ind1 = i;
                        count++;
                    }
                    else if (model.friday[i] == 1 && count == 1)
                    {
                        ind2 = i;
                        model.friday[i] = 0;
                        break;

                    }
                }
                for (int i = ind1; i < ind2; i++)
                    model.friday[i] = 1;
            }
           

        }
    }
}